package com.wsh.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsh.dto.sys.RoleDto;
import com.wsh.entity.sys.RoleEntity;
import com.wsh.mapper.sys.RoleDao;
import com.wsh.utils.PageUtils;
import com.wsh.sys.RoleService;
import com.wsh.utils.StringUtils;
import org.springframework.stereotype.Service;


/**
 * 权限业务接口实现类
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements RoleService {

    @Override
    public IPage<RoleEntity> getList(RoleDto roleDto) {
        // 分页数据处理
        IPage<RoleEntity> pages = PageUtils.getPage(roleDto);

        String name = roleDto.getName();
        // 分页查询处理
        IPage<RoleEntity> page =  baseMapper.selectPage(pages, new QueryWrapper<RoleEntity>()
            .like(StringUtils.isNoneBlank(name), "name", name)
        );

        return page;
    }
}
